#ifndef NETWORKDEVICE_HH_
# define NETWORKDEVICE_HH_

# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>

# include "common/constants.h"

// BSD server style
// 'a little bit' too C-style
// or cd code it in .c files and compile with gcc...

/** Abstract Class
 */
class NetworkDevice
{
    public:
        NetworkDevice();
        virtual ~NetworkDevice();
        void setPort(char* port);

    protected:
        /** prints \param msg to stderr if DEBUG is defined
         ** append error msg to log file
         */
        void displayError(char const* msg);

        // rly need this here ? (cd send to (resp.) server / client)
        // virtual void init();
        // virtual void init(char* portString);

        /** fills hints structure, client / server side dependant
         */
        virtual void buildHints() = 0;

        // NOTE: why can't we define this here ?
        // (Server.cc:18:30: erreur: class ‘Server’ does not have any field named ‘_port’)
        // added in Server.hh

        // struct addrinfo _hints;
        char* _port; // shd be an int

        // struct addrinfo *_result, *_rp;
        // int _sfd, _s;
        // struct sockaddr_storage _peerAddr;
        // socklen_t _peerAddrLen;
        // ssize_t _nread;
        // char _buf[SERVER_BUF_SIZE];
};

#endif // NETWORKDEVICE_HH_
